#ifndef _C_CPU_INFO_H_INCLUDED_
#define _C_CPU_INFO_H_INCLUDED_

#include <JeayeSDK/JeayeSDK.h>

/* Need to do this here because intrin.h has C++ code in it */
/* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */
#if defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_IX86) || defined(_M_X64))
    #include <intrin.h>

    #ifndef _WIN64
        #define __MMX__
        #define __3dNOW__
    #endif

    #define __SSE__
    #define __SSE2__

    #elif defined(__MINGW64_VERSION_MAJOR)
        #include <intrin.h>
    #else

        #ifdef __ALTIVEC__
            #if HAVE_ALTIVEC_H && !defined(__APPLE_ALTIVEC__)
                #include <altivec.h>
                #undef pixel
            #endif
        #endif

        #ifdef __MMX__
            #include <mmintrin.h>
        #endif

        #ifdef __3dNOW__
            #include <mm3dnow.h>
        #endif

        #ifdef __SSE__
            #include <xmmintrin.h>
        #endif

        #ifdef __SSE2__
            #include <emmintrin.h>
        #endif
#endif


/* This is a guess for the cacheline size used for padding.
 * Most x86 processors have a 64 byte cache line.
 * The 64-bit PowerPC processors have a 128 byte cache line.
 * We'll use the larger value to be generally safe.
 */
#define CC_CACHELINE_SIZE  128

/**
 *  This function returns the number of CPU cores available.
 */
JEAYESDK_API int c_cpu_count(void);

JEAYESDK_API const TCHAR* c_cpu_sn();
JEAYESDK_API const TCHAR* c_cpu_type(void);
JEAYESDK_API const TCHAR* c_cpu_name(void);
/**
 *  This function returns the L1 cache line size of the CPU
 *
 *  This is useful for determining multi-threaded structure padding
 *  or SIMD prefetch sizes.
 */
JEAYESDK_API int c_cpu_cache_line_size(void);

#define CPU_HAS_RDTSC   0x00000001
#define CPU_HAS_ALTIVEC 0x00000002
#define CPU_HAS_MMX     0x00000004
#define CPU_HAS_3DNOW   0x00000008
#define CPU_HAS_SSE     0x00000010
#define CPU_HAS_SSE2    0x00000020
#define CPU_HAS_SSE3    0x00000040
#define CPU_HAS_SSE41   0x00000100
#define CPU_HAS_SSE42   0x00000200
#define CPU_HAS_AVX     0x00000400
/**
 *  This function returns CPU have features.
 */
JEAYESDK_API UINT32 c_cpu_features(void);
/*
 *  This function returns the amount of RAM configured in the system, in MB.
 */
JEAYESDK_API int c_system_RAM(void);


#endif /* _C_CC_CPU_INFO_H_INCLUDED_ */

